package com.kc.web.controller.business;

import cn.hutool.core.date.DateUtil;
import com.kc.business.domain.dto.BizOrderCompareStatisticsDTO;
import com.kc.business.domain.order.dto.*;
import com.kc.business.domain.order.entity.BizCancelOrderStatistics;
import com.kc.business.domain.order.entity.BizOrderStatistics;
import com.kc.business.domain.query.BizOrderStatisticsQuery;
import com.kc.business.domain.vo.KcOrderGoodsVo;
import com.kc.business.domain.vo.KcUserStatisticsVO;
import com.kc.business.service.BizCancelOrderStatisticsService;
import com.kc.business.service.BizOrderStatisticsDataService;
import com.kc.business.service.BizOrderStatisticsService;
import com.kc.business.service.IBizUserStatisticsService;
import com.kc.common.constant.BizConstants;
import com.kc.common.core.domain.AjaxResult;
import com.kc.common.utils.StringUtils;
import com.kc.common.utils.base.BeanUtils;
import com.kc.common.utils.poi.ExcelUtil;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @ClassName KcOrderStatisticsController
 * @Description 订单统计相关
 * @Author wangdongliang
 * @Date 2021/5/19 15:37
 */
@RequestMapping(value = "/business/orderStatistics")
@RestController
@Slf4j
public class BizOrderStatisticsController {
    private List<String> colorList = Arrays.asList("#5B8FF9", "#5AD8A6","#5D7092","#F6BD16","#E8684A");
    @Resource
    private BizOrderStatisticsService orderStatisticsService;
    @Resource
    private BizCancelOrderStatisticsService bizCancelOrderStatisticsService;
    @Resource
    private BizOrderStatisticsDataService bizOrderStatisticsDataService;
    @Resource
    private IBizUserStatisticsService bizUserStatisticsService;
    @PreAuthorize("@ss.hasPermi('business:orderStatistics:getSaleOrderDataTotal')")
    @GetMapping("/getSaleOrderDataTotal")
    public AjaxResult getSaleOrderDataTotal(BizOrderStatisticsQuery bizOrderStatisticsQuery){
        String tablename = "kc_order_statistics";
        bizOrderStatisticsQuery.setTablename(tablename);
        List<BizOrderStatistics> bizOrderStatisticsList = bizOrderStatisticsDataService.getSaleData(bizOrderStatisticsQuery);
        //统计数据
        //订单量
        int orderNum = 0;
        //下单人数
        int orderUserNum = 0;
        //商品交易总额(GMV)
        int orderTotalMoney = 0;
        //客单价
        int singleUserMoney = 0;
        for (BizOrderStatistics bizOrderStatistics : bizOrderStatisticsList){
            orderNum += bizOrderStatistics.getOrderNum();
            orderUserNum += bizOrderStatistics.getOrderUserNum();
            orderTotalMoney += bizOrderStatistics.getOrderMoney().intValue();
            if(bizOrderStatistics.getOrderUserNum() != 0){
                bizOrderStatistics.setSingleUserMoney((bizOrderStatistics.getOrderMoney().intValue()/bizOrderStatistics.getOrderUserNum()));
            }
        }
        if(orderUserNum != 0){
            singleUserMoney = (orderTotalMoney/orderUserNum);
        }
        List<BizOrderTotalDTO> orderTotalDTOS = new ArrayList<>();
        orderTotalDTOS.add(new BizOrderTotalDTO("GMV","OrderMoney",orderTotalMoney,0));
        orderTotalDTOS.add(new BizOrderTotalDTO("订单量","OrderNum",orderNum,1));
        orderTotalDTOS.add(new BizOrderTotalDTO("下单人数","OrderUserNum",orderUserNum,2));
        orderTotalDTOS.add(new BizOrderTotalDTO("客单价","SingleUserMoney",singleUserMoney,3));
        return AjaxResult.success(orderTotalDTOS);

    }
    @PreAuthorize("@ss.hasPermi('business:orderStatistics:getSaleOrderData')")
    @GetMapping("/getSaleOrderData")
    public AjaxResult getOrderData(BizOrderStatisticsQuery bizOrderStatisticsQuery) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        String tablename = "kc_order_statistics";
        bizOrderStatisticsQuery.setTablename(tablename);
        List<BizOrderStatistics> bizOrderStatisticsList = bizOrderStatisticsDataService.getSaleData(bizOrderStatisticsQuery);
        String attributeName = "OrderUserNum";
        if(StringUtils.isNotEmpty(bizOrderStatisticsQuery.getAttributeName())){
            attributeName = bizOrderStatisticsQuery.getAttributeName();
        }

        //计算同比环比
        List<BizOrderCompareStatisticsDTO>  bizOrderStatisticsDTOList = orderStatisticsService.getCompareDataByDate(bizOrderStatisticsList, bizOrderStatisticsQuery, attributeName);
        List<String> dateList = bizOrderStatisticsList.stream().map(item->{return StringUtils.isNotEmpty(item.getYearDay()) && bizOrderStatisticsQuery.getIsQuarter() == 0?item.getYearDay():bizOrderStatisticsQuery.getIsQuarter() == 0?item.getCurrMonth(): item.getCurrYear()+"-"+item.getYearQ();}).collect(Collectors.toList());
        //颜色
        List<String> color = Arrays.asList("#1B6AE0","#E8684A","#F6BD16");
        //List<BizOrderCompareStatisticsDTO> bizOrderStatisticsDTOList = orderStatisticsService.getCompareDataByDate(bizOrderStatisticsList,bizOrderStatisticsQuery.getBeginDate(),"OrderUserNum");
        Map<String,Object> map = new HashMap<>();
        map.put("color",color);
        map.put("dateList",dateList);
        map.put("dataList",bizOrderStatisticsDTOList);

        //折线数据，直接从上面数据值获取
        Map<String,Object> brokenLine = new HashMap<>();
        brokenLine.put("color",Arrays.asList("#E8684A","#5B8FF9"));
        brokenLine.put("data",dateList);
        //拼装数据
        List<BizOrderStatisticsBrokenLineDataDTO> brokenLineDataDTOS = new ArrayList<>();
        brokenLineDataDTOS.add(new BizOrderStatisticsBrokenLineDataDTO("环比","line","总量",true,bizOrderStatisticsDTOList.get(1).getData()));
        brokenLineDataDTOS.add(new BizOrderStatisticsBrokenLineDataDTO("同比","line","总量",true,bizOrderStatisticsDTOList.get(2).getData()));
        brokenLine.put("series",brokenLineDataDTOS);

        Map<String,Object> allDataMap = new HashMap<>();
        allDataMap.put("columnar",map);
        allDataMap.put("brokenLine",brokenLine);
        //计算底部统计数据
        int sum = bizOrderStatisticsDataService.getSun(bizOrderStatisticsDTOList.get(0).getData());
        Map<String,Object> footDate = new HashMap<>();
        List<BizOrderTotalDTO> orderTotalDTOS = new ArrayList<>();
        orderTotalDTOS.add(new BizOrderTotalDTO("所选日期均值","",sum/bizOrderStatisticsDataService.getDays(bizOrderStatisticsQuery),0));
        orderTotalDTOS.add(new BizOrderTotalDTO("近7日均值","",bizOrderStatisticsDataService.getSaleDateByWeek(attributeName)/7,0));
        orderTotalDTOS.add(new BizOrderTotalDTO("近30日均值","",bizOrderStatisticsDataService.getSaleDateByMonth(attributeName)/30,0));
        allDataMap.put("footData",orderTotalDTOS);
        return AjaxResult.success(allDataMap);
    }

    @PreAuthorize("@ss.hasPermi('business:orderStatistics:getCancelOrderDataTotal')")
    @GetMapping("/getCancelOrderDataTotal")
    public AjaxResult getCancelOrderDataTotal(BizOrderStatisticsQuery bizOrderStatisticsQuery){
        //取消订单次数
        int orderNum = 0;
        //取消订单用户数
        int orderUserNum = 0;
        List<BizCancelOrderStatistics> bizOrderStatisticsList = bizOrderStatisticsDataService.getCancelData(bizOrderStatisticsQuery);
        //计算取消订单次数和取消订单用户数
        for(BizCancelOrderStatistics bizCancelOrderStatistics : bizOrderStatisticsList){
            orderNum += bizCancelOrderStatistics.getOrderNum();
            orderUserNum += bizCancelOrderStatistics.getOrderUserNum();
        }
        List<BizOrderTotalDTO> orderTotalDTOS = new ArrayList<>();
        orderTotalDTOS.add(new BizOrderTotalDTO("取消订单次数","OrderNum",orderNum,0));
        orderTotalDTOS.add(new BizOrderTotalDTO("取消订单用户数","OrderUserNum",orderUserNum,1));
        return AjaxResult.success(orderTotalDTOS);
    }

    @PreAuthorize("@ss.hasPermi('business:orderStatistics:getCancelOrderData')")
    @GetMapping("/getCancelOrderData")
    public AjaxResult getCancelOrderData(BizOrderStatisticsQuery bizOrderStatisticsQuery,HttpServletResponse response) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        String tablename = "kc_cancel_order_statistics";
        bizOrderStatisticsQuery.setTablename(tablename);
        List<BizCancelOrderStatistics> bizOrderStatisticsList = bizOrderStatisticsDataService.getCancelData(bizOrderStatisticsQuery);

        String attributeName = "OrderNum";
        if(StringUtils.isNotEmpty(bizOrderStatisticsQuery.getAttributeName())){
            attributeName = bizOrderStatisticsQuery.getAttributeName();
        }

        List<BizOrderCompareStatisticsDTO>  bizOrderStatisticsDTOList = bizCancelOrderStatisticsService.getCompareDataByDate(bizOrderStatisticsList, bizOrderStatisticsQuery, attributeName);
        List<String> dateList = new ArrayList<>();
        for(BizCancelOrderStatistics bizCancelOrderStatistics : bizOrderStatisticsList){
            if(bizOrderStatisticsQuery.getIsQuarter() == 1){
                dateList.add(bizCancelOrderStatistics.getCurrYear()+"-"+bizCancelOrderStatistics.getYearQ());
            }else if(StringUtils.isNotEmpty(bizCancelOrderStatistics.getYearDay())){
                dateList.add(bizCancelOrderStatistics.getYearDay());
            }else{
                dateList.add(bizCancelOrderStatistics.getCurrMonth());
            }
        }
        Map<String,Object> map = new HashMap<>();
        map.put("dateList",dateList);
        map.put("dataList",bizOrderStatisticsDTOList);

        Map<String,Object> allDataMap = new HashMap<>();
        allDataMap.put("columnar",map);
        //折线数据，直接从上面数据值获取
        Map<String,Object> brokenLine = new HashMap<>();
        brokenLine.put("color",Arrays.asList("#E8684A","#5B8FF9"));
        brokenLine.put("data",dateList);
        //拼装数据
        List<BizOrderStatisticsBrokenLineDataDTO> brokenLineDataDTOS = new ArrayList<>();
        brokenLineDataDTOS.add(new BizOrderStatisticsBrokenLineDataDTO("环比","line","总量",true,bizOrderStatisticsDTOList.get(1).getData()));
        brokenLineDataDTOS.add(new BizOrderStatisticsBrokenLineDataDTO("同比","line","总量",true,bizOrderStatisticsDTOList.get(2).getData()));
        brokenLine.put("series",brokenLineDataDTOS);
        allDataMap.put("brokenLine",brokenLine);
        Map<String,Object> footDate = new HashMap<>();
        //计算底部统计数据
        int sum = bizOrderStatisticsDataService.getSun(bizOrderStatisticsDTOList.get(0).getData());
        List<BizOrderTotalDTO> orderTotalDTOS = new ArrayList<>();
        orderTotalDTOS.add(new BizOrderTotalDTO("所选日期均值","",sum/bizOrderStatisticsDataService.getDays(bizOrderStatisticsQuery),0));
        orderTotalDTOS.add(new BizOrderTotalDTO("近7日均值","",bizOrderStatisticsDataService.getCancelOrderDateByWeek(attributeName)/7,0));
        orderTotalDTOS.add(new BizOrderTotalDTO("近30日均值","",bizOrderStatisticsDataService.getCancelOrderDateByMonth(attributeName)/30,0));
        allDataMap.put("footData",orderTotalDTOS);
        return AjaxResult.success(allDataMap);


        //todo 数据导出，后面使用
//        if(bizOrderStatisticsQuery.getExport().equals(1)){
//            List<BizOrderStatisticsExportDTO> statisticsExportDTOList = new ArrayList<>();
//            int len = dateList.size();
//            for(int i = 0;i<len;i++){
//                statisticsExportDTOList.add(new BizOrderStatisticsExportDTO(dateList.get(i),bizOrderStatisticsDTOList.get(0).getData().get(i),bizOrderStatisticsDTOList.get(1).getData().get(i),bizOrderStatisticsDTOList.get(2).getData().get(i)));
//            }
//            log.info("要导出的数据{}",statisticsExportDTOList);
//            //数据导出
//            //日期
//            ExcelUtil<BizOrderStatisticsExportDTO> util = new ExcelUtil<>(BizOrderStatisticsExportDTO.class);
//            Workbook workbook = null;
//            try {
//                DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
//                workbook = util.exportExcelWithoutPersist(statisticsExportDTOList, "统计表");
//                response.setContentType("application/octet-stream");
//                response.setHeader("Content-disposition", String.format("attachment;filename=%s.xlsx",
//                        URLEncoder.encode(String.format("统计表"),
//                                "UTF-8")));
//                response.flushBuffer();
//                workbook.write(response.getOutputStream());
//            } catch (Exception e) {
//                log.error("下载文件失败", e);
//            } finally {
//                if (null != workbook) {
//                    try {
//                        workbook.close();
//                    } catch (IOException e) {
//                        e.printStackTrace();
//                    }
//                }
//            }
//        }

    }
    @PreAuthorize("@ss.hasPermi('business:orderStatistics:getRefundStatisticsTotal')")
    @GetMapping("/getRefundStatisticsTotal")
    public AjaxResult getRefundStatisticsTotal(BizOrderStatisticsQuery bizOrderStatisticsQuery){
        //退款订单次数
        int orderNum = 0;
        //退款订单用户数
        int orderUserNum = 0;
        List<BizOrderStatistics> bizOrderStatisticsList = orderStatisticsService.getKcRefundStatistics(bizOrderStatisticsQuery);
        for (BizOrderStatistics bizOrderStatistics : bizOrderStatisticsList){
            orderNum += bizOrderStatistics.getOrderNum();
            orderUserNum += bizOrderStatistics.getOrderUserNum();
        }

        List<BizOrderTotalDTO> orderTotalDTOS = new ArrayList<>();
        orderTotalDTOS.add(new BizOrderTotalDTO("退款订单次数","OrderNum",orderNum,0));
        orderTotalDTOS.add(new BizOrderTotalDTO("退款订单用户数","OrderUserNum",orderUserNum,1));
        return AjaxResult.success(orderTotalDTOS);
    }
    @PreAuthorize("@ss.hasPermi('business:orderStatistics:getRefundStatistics')")
    @GetMapping("/getRefundStatistics")
    public AjaxResult getRefundStatistics(BizOrderStatisticsQuery bizOrderStatisticsQuery) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
        List<BizOrderStatistics> bizOrderStatisticsList = orderStatisticsService.getKcRefundStatistics(bizOrderStatisticsQuery);
        String attributeName = "OrderNum";
        if(StringUtils.isNotEmpty(bizOrderStatisticsQuery.getAttributeName())){
            attributeName = bizOrderStatisticsQuery.getAttributeName();
        }
        //计算同比环比
        List<String> dateList = bizOrderStatisticsList.stream().map(item->{return StringUtils.isNotEmpty(item.getYearDay())?item.getYearDay():item.getCurrMonth();}).collect(Collectors.toList());
        List<BizOrderCompareStatisticsDTO>  bizOrderStatisticsDTOList = orderStatisticsService.getRefundCompareData(bizOrderStatisticsList, bizOrderStatisticsQuery, attributeName);
        Map<String,Object> map = new HashMap<>();
        map.put("dateList",dateList);
        map.put("dataList",bizOrderStatisticsDTOList);

        Map<String,Object> allDataMap = new HashMap<>();
        allDataMap.put("columnar",map);
        //折线数据，直接从上面数据值获取
        Map<String,Object> brokenLine = new HashMap<>();
        brokenLine.put("color",Arrays.asList("#E8684A","#5B8FF9"));
        brokenLine.put("data",dateList);
        //拼装数据
        List<BizOrderStatisticsBrokenLineDataDTO> brokenLineDataDTOS = new ArrayList<>();
        brokenLineDataDTOS.add(new BizOrderStatisticsBrokenLineDataDTO("环比","line","总量",true,bizOrderStatisticsDTOList.get(1).getData()));
        brokenLineDataDTOS.add(new BizOrderStatisticsBrokenLineDataDTO("同比","line","总量",true,bizOrderStatisticsDTOList.get(2).getData()));
        brokenLine.put("series",brokenLineDataDTOS);
        allDataMap.put("brokenLine",brokenLine);
        //计算底部统计数据
        int sum = bizOrderStatisticsDataService.getSun(bizOrderStatisticsDTOList.get(0).getData());
        List<BizOrderTotalDTO> orderTotalDTOS = new ArrayList<>();
        orderTotalDTOS.add(new BizOrderTotalDTO("所选日期均值","",sum/bizOrderStatisticsDataService.getDays(bizOrderStatisticsQuery),0));
        orderTotalDTOS.add(new BizOrderTotalDTO("近7日均值","",bizOrderStatisticsDataService.getRefundOrderDateByWeek(attributeName)/7,0));
        orderTotalDTOS.add(new BizOrderTotalDTO("近30日均值","",bizOrderStatisticsDataService.getRefundOrderDateByMonth(attributeName)/30,0));
        allDataMap.put("footData",orderTotalDTOS);
        return AjaxResult.success(allDataMap);
    }

//    @GetMapping("/exportOrderData")
//    @PreAuthorize("@ss.hasPermi('business:orderStatistics:exportOrderData')")
//    public AjaxResult export(BizOrderStatisticsQuery bizOrderStatisticsQuery, HttpServletResponse response) throws Exception {
//
//    }

    /**
     * 当日数据
     * @return
     */
    @PreAuthorize("@ss.hasPermi('business:orderStatistics:sameDayData')")
    @GetMapping("/sameDayData")
    public AjaxResult sameDayData(){
        String currDate = DateUtil.now().substring(0,10);
        BizOrderStatistics orderStatistics = orderStatisticsService.getCurrData(currDate,0,0,0);
        //订单量
        int orderNum = orderStatistics.getOrderNum();
        //下单人数
        int orderUserNum = orderStatistics.getOrderUserNum();
        //商品交易总额(GMV)
        int orderTotalMoney = orderStatistics.getOrderMoney().intValue();
        //客单价
        int singleUserMoney = 0;
        if(orderUserNum != 0) {
            singleUserMoney = (orderTotalMoney / orderUserNum);
        }


        List<BizOrderStatisticsDataDTO> orderStatisticsDataDTOList = new ArrayList<>();
        orderStatisticsDataDTOList.add(new BizOrderStatisticsDataDTO("订单量",orderNum+"","订单量"+orderNum,"#9CE8CA",0));
        orderStatisticsDataDTOList.add(new BizOrderStatisticsDataDTO("下单人数",orderUserNum+"","下单人数"+orderUserNum,"#9EA9BE",1));
        orderStatisticsDataDTOList.add(new BizOrderStatisticsDataDTO("客单价",singleUserMoney+"","客单价"+singleUserMoney,"#FAD773",2));
        orderStatisticsDataDTOList.add(new BizOrderStatisticsDataDTO("商品交易总额(GMV)",orderTotalMoney+"","商品交易总额(GMV)"+orderTotalMoney,"#9DBCFB",3));
        return AjaxResult.success(orderStatisticsDataDTOList);
    }


    /**
     * 根据时间范围获取数据
     * @return
     */
    @PreAuthorize("@ss.hasPermi('business:orderStatistics:getDataByDay')")
    @GetMapping("/getDataByDay")
    public AjaxResult getDataByDay(BizOrderStatisticsQuery bizOrderStatisticsQuery){
        //销售数据
        List<BizOrderStatistics> saleOrderStatisticsList = bizOrderStatisticsDataService.getSaleData(bizOrderStatisticsQuery);
        //log.info("销售订单数据{}",saleOrderStatisticsList);
        //取消订单数据
        List<BizCancelOrderStatistics> cancelOrderStatisticsList = bizOrderStatisticsDataService.getCancelData(bizOrderStatisticsQuery);
        //log.info("取消订单数据{}",cancelOrderStatisticsList);
        //退款数据
        List<BizOrderStatistics> refundOrderStatisticsList = orderStatisticsService.getKcRefundStatistics(bizOrderStatisticsQuery);

        //订单量
        int orderNum = 0;
        //下单人数
        int orderUserNum = 0;
        //商品交易总额(GMV)
        int orderTotalMoney = 0;
        //客单价
        int singleUserMoney = 0;
        //取消订单次数
        int calcelOrderNum = 0;
        //取消订单用户数
        int cancelOrderUserNum = 0;
        //申请退款次数
        int refundOrderNum = 0;
        //申请退款用户数
        int refundOrderUserNum = 0;

        int len = saleOrderStatisticsList.size();
        for(int i = 0;i < len;i++){
            orderNum += saleOrderStatisticsList.get(i).getOrderNum();
            orderUserNum += saleOrderStatisticsList.get(i).getOrderUserNum();
            orderTotalMoney += saleOrderStatisticsList.get(i).getOrderMoney().intValue();
            calcelOrderNum += cancelOrderStatisticsList.get(i).getOrderNum();
            cancelOrderUserNum += cancelOrderStatisticsList.get(i).getOrderUserNum();
            refundOrderNum += refundOrderStatisticsList.get(i).getOrderNum();
            refundOrderUserNum += refundOrderStatisticsList.get(i).getOrderUserNum();
        }

        if(orderUserNum != 0) {
            singleUserMoney = (orderTotalMoney / orderUserNum);
        }

        List<BizOrderStatisticsDataDTO> orderStatisticsDataDTOList = new ArrayList<>();
        orderStatisticsDataDTOList.add(new BizOrderStatisticsDataDTO("订单量",orderNum+"","订单量"+orderNum,"#9CE8CA",1));
        orderStatisticsDataDTOList.add(new BizOrderStatisticsDataDTO("下单人数",orderUserNum+"","下单人数"+orderUserNum,"#9EA9BE",2));
        orderStatisticsDataDTOList.add(new BizOrderStatisticsDataDTO("客单价",singleUserMoney+"","客单价"+singleUserMoney,"#FAD773",3));
        orderStatisticsDataDTOList.add(new BizOrderStatisticsDataDTO("商品交易总额(GMV)",orderTotalMoney+"","商品交易总额(GMV)"+orderTotalMoney,"#9DBCFB",4));

        orderStatisticsDataDTOList.add(new BizOrderStatisticsDataDTO("取消订单次数",calcelOrderNum+"","取消订单次数"+calcelOrderNum,"#A7DEF4",5));
        orderStatisticsDataDTOList.add(new BizOrderStatisticsDataDTO("取消订单用户数",cancelOrderUserNum+"","取消订单用户数"+cancelOrderUserNum,"#BEA9DF",6));
        orderStatisticsDataDTOList.add(new BizOrderStatisticsDataDTO("申请退款次数",refundOrderNum+"","申请退款次数"+refundOrderNum,"#FFC494",7));
        orderStatisticsDataDTOList.add(new BizOrderStatisticsDataDTO("申请退款用户数",refundOrderUserNum+"","申请退款用户数"+refundOrderUserNum,"#F1A492",8));
        return AjaxResult.success(orderStatisticsDataDTOList);
    }

    /**
     * 根据时间范围获取图表数据
     * @return
     */
    @PreAuthorize("@ss.hasPermi('business:orderStatistics:getLineChartByDay')")
    @PostMapping("/getLineChartByDay")
    public AjaxResult getLineChartByDay(@RequestBody BizOrderStatisticsQuery bizOrderStatisticsQuery,HttpServletResponse response){
        //订单量
        List<String> orderNum = new ArrayList<>();
        //下单人数
        List<String> orderUserNum = new ArrayList<>();;
        //商品交易总额(GMV)
        List<String> orderTotalMoney = new ArrayList<>();;
        //客单价
        List<String> singleUserMoney = new ArrayList<>();;
        //取消订单次数
        List<String> calcelOrderNum = new ArrayList<>();;
        //取消订单用户数
        List<String> cancelOrderUserNum = new ArrayList<>();;
        //申请退款次数
        List<String> refundOrderNum = new ArrayList<>();;
        //申请退款用户数
        List<String> refundOrderUserNum = new ArrayList<>();;
        //销售数据
        List<BizOrderStatistics> saleOrderStatisticsList = bizOrderStatisticsDataService.getSaleData(bizOrderStatisticsQuery);
        //log.info("销售订单数据{}",saleOrderStatisticsList);
        //取消订单数据
        List<BizCancelOrderStatistics> cancelOrderStatisticsList = bizOrderStatisticsDataService.getCancelData(bizOrderStatisticsQuery);
        //log.info("取消订单数据{}",cancelOrderStatisticsList);
        //退款数据
        List<BizOrderStatistics> refundOrderStatisticsList = orderStatisticsService.getKcRefundStatistics(bizOrderStatisticsQuery);
        int len = saleOrderStatisticsList.size();
        List<String> dateList = new ArrayList<>();
        //数据导出使用
        List<BizOrderStatisticsLineChartExportDataDTO> exportDataDTOS = new ArrayList<>();
        for(int i = 0;i < len;i++){
            String date = saleOrderStatisticsList.get(i).getYearDay();
            dateList.add(date);
            orderNum.add(saleOrderStatisticsList.get(i).getOrderNum()+"");
            orderUserNum.add(saleOrderStatisticsList.get(i).getOrderUserNum()+"");
            orderTotalMoney.add(saleOrderStatisticsList.get(i).getOrderMoney()+"");
            int singleMoney = 0;
            if(saleOrderStatisticsList.get(i).getOrderUserNum() == 0){
                //singleUserMoney.add("0");
            }else{
                singleMoney = (saleOrderStatisticsList.get(i).getOrderMoney().intValue()/saleOrderStatisticsList.get(i).getOrderUserNum());
            }
            singleUserMoney.add(singleMoney + "");
            calcelOrderNum.add(cancelOrderStatisticsList.get(i).getOrderNum()+"");
            cancelOrderUserNum.add(cancelOrderStatisticsList.get(i).getOrderUserNum()+"");
            refundOrderNum.add(refundOrderStatisticsList.get(i).getOrderNum()+"");
            refundOrderUserNum.add(refundOrderStatisticsList.get(i).getOrderUserNum()+"");
            //处理数据导出数据
            BizOrderStatisticsLineChartExportDataDTO exportDataDTO = new BizOrderStatisticsLineChartExportDataDTO();
            exportDataDTO.setDate(date);
            exportDataDTO.setOrderNum(saleOrderStatisticsList.get(i).getOrderNum());
            exportDataDTO.setOrderUserNum(saleOrderStatisticsList.get(i).getOrderUserNum());
            exportDataDTO.setOrderTotalMoney(saleOrderStatisticsList.get(i).getOrderMoney().intValue());
            exportDataDTO.setSingleUserMoney(singleMoney);
            exportDataDTO.setCalcelOrderNum(cancelOrderStatisticsList.get(i).getOrderNum());
            exportDataDTO.setCancelOrderUserNum(cancelOrderStatisticsList.get(i).getOrderUserNum());
            exportDataDTO.setRefundOrderNum(refundOrderStatisticsList.get(i).getOrderNum());
            exportDataDTO.setRefundOrderUserNum(refundOrderStatisticsList.get(i).getOrderUserNum());
            exportDataDTOS.add(exportDataDTO);
        }
        List<BizOrderStatisticsLineChartDataDTO> dataList = new ArrayList<>();
        //BizOrderStatisticsLineChartDataDTO info = new BizOrderStatisticsLineChartDataDTO("搜索引擎","line","总量",true,null);
        for (Integer i : bizOrderStatisticsQuery.getIndexes()){
            switch (i){
                case 1:
                    BizOrderStatisticsLineChartDataDTO orderNumInfo = new BizOrderStatisticsLineChartDataDTO("搜索引擎","line","总量",true,null,new BizColorDTO("#9CE8CA"));
                    orderNumInfo.setName("订单量");
                    orderNumInfo.setData(orderNum);
                    dataList.add(orderNumInfo);
                    break;
                case 2:
                    BizOrderStatisticsLineChartDataDTO orderUserNumInfo = new BizOrderStatisticsLineChartDataDTO("搜索引擎","line","总量",true,null,new BizColorDTO("#9EA9BE"));
                    orderUserNumInfo.setName("下单人数");
                    orderUserNumInfo.setData(orderUserNum);
                    dataList.add(orderUserNumInfo);
                    break;
                case 3:
                    BizOrderStatisticsLineChartDataDTO singleUserMoneyInfo = new BizOrderStatisticsLineChartDataDTO("搜索引擎","line","总量",true,null,new BizColorDTO("#FAD773"));
                    singleUserMoneyInfo.setName("客单价");
                    singleUserMoneyInfo.setData(singleUserMoney);
                    dataList.add(singleUserMoneyInfo);
                    break;
                case 4:
                    BizOrderStatisticsLineChartDataDTO orderTotalMoneyInfo = new BizOrderStatisticsLineChartDataDTO("搜索引擎","line","总量",true,null,new BizColorDTO("#9DBCFB"));
                    orderTotalMoneyInfo.setName("商品交易总额(GMV)");
                    orderTotalMoneyInfo.setData(orderTotalMoney);
                    dataList.add(orderTotalMoneyInfo);
                    break;
                case 5:
                    BizOrderStatisticsLineChartDataDTO calcelOrderNumInfo = new BizOrderStatisticsLineChartDataDTO("搜索引擎","line","总量",true,null,new BizColorDTO("#A7DEF4"));
                    calcelOrderNumInfo.setName("取消订单次数");
                    calcelOrderNumInfo.setData(calcelOrderNum);
                    dataList.add(calcelOrderNumInfo);
                    break;
                case 6:
                    BizOrderStatisticsLineChartDataDTO cancelOrderUserNumInfo = new BizOrderStatisticsLineChartDataDTO("搜索引擎","line","总量",true,null,new BizColorDTO("#BEA9DF"));
                    cancelOrderUserNumInfo.setName("取消订单用户数");
                    cancelOrderUserNumInfo.setData(cancelOrderUserNum);
                    dataList.add(cancelOrderUserNumInfo);
                    break;
                case 7:
                    BizOrderStatisticsLineChartDataDTO refundOrderNumInfo = new BizOrderStatisticsLineChartDataDTO("搜索引擎","line","总量",true,null,new BizColorDTO("#FFC494"));
                    refundOrderNumInfo.setName("退款订单次数");
                    refundOrderNumInfo.setData(refundOrderNum);
                    dataList.add(refundOrderNumInfo);
                    break;
                case 8:
                    BizOrderStatisticsLineChartDataDTO refundOrderUserNumInfo = new BizOrderStatisticsLineChartDataDTO("搜索引擎","line","总量",true,null,new BizColorDTO("#F1A492"));
                    refundOrderUserNumInfo.setName("退款订单用户数");
                    refundOrderUserNumInfo.setData(refundOrderUserNum);
                    dataList.add(refundOrderUserNumInfo);
                    break;
            }
        }
        Map<String,Object> map = new HashMap<>();
        map.put("dateList",dateList);
        map.put("list",dataList);
        return AjaxResult.success(map);
    }

    /**
     * 根据时间范围获取图表数据
     * @return
     */
    @PreAuthorize("@ss.hasPermi('business:orderStatistics:download')")
    @GetMapping("/download")
    public AjaxResult download(BizOrderStatisticsQuery bizOrderStatisticsQuery,HttpServletResponse response){
        //销售数据
        List<BizOrderStatistics> saleOrderStatisticsList = bizOrderStatisticsDataService.getSaleData(bizOrderStatisticsQuery);
        //log.info("销售订单数据{}",saleOrderStatisticsList);
        //取消订单数据
        List<BizCancelOrderStatistics> cancelOrderStatisticsList = bizOrderStatisticsDataService.getCancelData(bizOrderStatisticsQuery);
        //log.info("取消订单数据{}",cancelOrderStatisticsList);
        //退款数据
        List<BizOrderStatistics> refundOrderStatisticsList = orderStatisticsService.getKcRefundStatistics(bizOrderStatisticsQuery);
        int len = saleOrderStatisticsList.size();
        List<String> dateList = new ArrayList<>();
        //数据导出使用
        List<BizOrderStatisticsLineChartExportDataDTO> exportDataDTOS = new ArrayList<>();
        for(int i = 0;i < len;i++){
            String date = saleOrderStatisticsList.get(i).getYearDay();
            int singleMoney = 0;
            if(saleOrderStatisticsList.get(i).getOrderUserNum() == 0){
                //singleUserMoney.add("0");
            }else{
                singleMoney = (saleOrderStatisticsList.get(i).getOrderMoney().intValue()/saleOrderStatisticsList.get(i).getOrderUserNum());
            }
            //处理数据导出数据
            BizOrderStatisticsLineChartExportDataDTO exportDataDTO = new BizOrderStatisticsLineChartExportDataDTO();
            exportDataDTO.setDate(date);
            exportDataDTO.setOrderNum(saleOrderStatisticsList.get(i).getOrderNum());
            exportDataDTO.setOrderUserNum(saleOrderStatisticsList.get(i).getOrderUserNum());
            exportDataDTO.setOrderTotalMoney(saleOrderStatisticsList.get(i).getOrderMoney().intValue());
            exportDataDTO.setSingleUserMoney(singleMoney);
            exportDataDTO.setCalcelOrderNum(cancelOrderStatisticsList.get(i).getOrderNum());
            exportDataDTO.setCancelOrderUserNum(cancelOrderStatisticsList.get(i).getOrderUserNum());
            exportDataDTO.setRefundOrderNum(refundOrderStatisticsList.get(i).getOrderNum());
            exportDataDTO.setRefundOrderUserNum(refundOrderStatisticsList.get(i).getOrderUserNum());
            exportDataDTOS.add(exportDataDTO);
        }
            //数据导出
            //日期
            ExcelUtil<BizOrderStatisticsLineChartExportDataDTO> util = new ExcelUtil<>(BizOrderStatisticsLineChartExportDataDTO.class);
            Workbook workbook = null;
            try {
                DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
                workbook = util.exportExcelWithoutPersist(exportDataDTOS, "统计表");
                response.setContentType("application/octet-stream");
                response.setHeader("Content-disposition", String.format("attachment;filename=%s.xlsx",
                        URLEncoder.encode(String.format("统计表"),
                                "UTF-8")));
                response.flushBuffer();
                workbook.write(response.getOutputStream());
            } catch (Exception e) {
                log.error("下载文件失败", e);
            } finally {
                if (null != workbook) {
                    try {
                        workbook.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }


        return AjaxResult.success();
    }

    /**
     * 销售订单按照性别统计
     * @return
     */
    @PreAuthorize("@ss.hasPermi('business:orderStatistics:getSaleStatisticsBySex')")
    @GetMapping("/getSaleStatisticsBySex")
    public AjaxResult getSaleStatisticsBySex(BizOrderStatisticsQuery bizOrderStatisticsQuery){
        List<BizOrderStatistics> bizOrderStatisticsList = bizOrderStatisticsDataService.getSaleData(bizOrderStatisticsQuery);
        //男性数量
        int manNum = 0;
        BigDecimal manMoney = new BigDecimal(0);
        //女性数量
        int womanNum = 0;
        BigDecimal wowanMoney = new BigDecimal(0);
        //未知性别数量
        int otherNum = 0;
        BigDecimal otherMoney = new BigDecimal(0);
        //总用户数
        int totalUserNum = 0;
        //总订单金额
        BigDecimal totalOrderMoney = new BigDecimal(0);

        for(BizOrderStatistics bizOrderStatistics : bizOrderStatisticsList){
            manNum += bizOrderStatistics.getManNum();
            womanNum += bizOrderStatistics.getWomanNum();
            otherNum += bizOrderStatistics.getOther();
            totalUserNum += bizOrderStatistics.getOrderUserNum();
            manMoney.add(bizOrderStatistics.getManOrderMoney());
            wowanMoney.add(bizOrderStatistics.getWomanOrderMoney());
            otherMoney.add(bizOrderStatistics.getOtherOrderMoney());
            totalOrderMoney.add(bizOrderStatistics.getOrderMoney());
        }
        //饼状图数据
        List<KcUserStatisticsVO> kcUserStatisticsVOS = new ArrayList<>();
        kcUserStatisticsVOS.add(new KcUserStatisticsVO(BizConstants.MAN,manNum+""));
        kcUserStatisticsVOS.add(new KcUserStatisticsVO(BizConstants.WOMAN,womanNum+""));
        kcUserStatisticsVOS.add(new KcUserStatisticsVO(BizConstants.OTHERSEX,otherNum+""));
        //列表数据
        List<BizSaleStatisticsBySexDTO> bizSaleStatisticsBySexDTOList = new ArrayList<>();
        boolean flag = totalOrderMoney.compareTo(new BigDecimal(0)) == 0;
        bizSaleStatisticsBySexDTOList.add(new BizSaleStatisticsBySexDTO(BizConstants.MAN,manNum,totalUserNum == 0?0+"%":(new BigDecimal(manNum).divide(new BigDecimal(totalUserNum),2,BigDecimal.ROUND_HALF_EVEN))+"%",manMoney, flag? 0+"%" :(manMoney.divide(totalOrderMoney,2,BigDecimal.ROUND_HALF_EVEN)+"%")));
        bizSaleStatisticsBySexDTOList.add(new BizSaleStatisticsBySexDTO(BizConstants.WOMAN,womanNum,womanNum == 0?0+"%":(new BigDecimal(womanNum).divide(new BigDecimal(totalUserNum),2,BigDecimal.ROUND_HALF_EVEN))+"%",wowanMoney,flag? 0+"%" :(wowanMoney.divide(totalOrderMoney,2,BigDecimal.ROUND_HALF_EVEN)+"%")));
        bizSaleStatisticsBySexDTOList.add(new BizSaleStatisticsBySexDTO(BizConstants.OTHERSEX,otherNum,otherNum == 0?0+"%":(new BigDecimal(otherNum).divide(new BigDecimal(totalUserNum),2,BigDecimal.ROUND_HALF_EVEN))+"%",otherMoney,flag ? 0+"%" :(otherMoney.divide(totalOrderMoney,2,BigDecimal.ROUND_HALF_EVEN)+"%")));

        Map<String,Object> map = new HashMap<>();
        map.put("pieChartData",kcUserStatisticsVOS);
        map.put("listData",bizSaleStatisticsBySexDTOList);
        return AjaxResult.success(map);
    }

    /**
     * 销售订单按照年齡统计
     * @return
     */
    @PreAuthorize("@ss.hasPermi('business:orderStatistics:getSaleStatisticsByAge')")
    @GetMapping("/getSaleStatisticsByAge")
    public AjaxResult getSaleStatisticsByAge(BizOrderStatisticsQuery bizOrderStatisticsQuery){
        List<BizOrderStatisticsByAgeSectionDTO> bizOrderStatisticsList = bizOrderStatisticsDataService.getSaleStatisticsByAge(bizOrderStatisticsQuery);

        //订单总金额
        BigDecimal totalOrderMoney = new BigDecimal(0);
        //订单总数量
        int totalUserNum = 0;
        //未知性别数据
        BigDecimal otherOrderMoney = new BigDecimal(0);
        int otherUserNum = 0;
        List<String> ageSection = bizUserStatisticsService.getAgeAection();
        Map<String,BizOrderStatisticsByAgeSectionDTO> map = new HashMap<>();
        for(BizOrderStatisticsByAgeSectionDTO bizOrderStatistics : bizOrderStatisticsList){
            if(StringUtils.isEmpty(bizOrderStatistics.getAgeSection())){
                otherUserNum += bizOrderStatistics.getUserNum();
                otherOrderMoney = otherOrderMoney.add(bizOrderStatistics.getOrderMoney());
            }else{
                map.put(bizOrderStatistics.getAgeSection(),bizOrderStatistics);
            }
            totalUserNum += bizOrderStatistics.getUserNum();
            totalOrderMoney = totalOrderMoney.add(bizOrderStatistics.getOrderMoney());
        }

        //列表数据
        List<BizSaleStatisticsBySexDTO> bizSaleStatisticsBySexDTOList = new ArrayList<>();
        boolean flag = totalOrderMoney.compareTo(new BigDecimal(0)) == 0;
        for(String age : ageSection){
            BizOrderStatisticsByAgeSectionDTO bizOrderStatisticsByAgeSectionDTO = map.get(age);
            if (bizOrderStatisticsByAgeSectionDTO != null && StringUtils.isNotEmpty(bizOrderStatisticsByAgeSectionDTO.getAgeSection())){
                bizSaleStatisticsBySexDTOList.add(new BizSaleStatisticsBySexDTO(age,bizOrderStatisticsByAgeSectionDTO.getUserNum(),totalUserNum == 0?0+"%":(new BigDecimal(bizOrderStatisticsByAgeSectionDTO.getUserNum()).divide(new BigDecimal(totalUserNum),2,BigDecimal.ROUND_HALF_EVEN))+"%",bizOrderStatisticsByAgeSectionDTO.getOrderMoney(), flag? 0+"%" :(bizOrderStatisticsByAgeSectionDTO.getOrderMoney().divide(totalOrderMoney,2,BigDecimal.ROUND_HALF_EVEN)+"%")));
            }else{
                bizSaleStatisticsBySexDTOList.add(new BizSaleStatisticsBySexDTO(age,0,"0%",new BigDecimal(0),"0%"));
            }
        }
        bizSaleStatisticsBySexDTOList.add(new BizSaleStatisticsBySexDTO("未知年龄",otherUserNum,totalUserNum == 0?0+"%":(new BigDecimal(otherUserNum).divide(new BigDecimal(totalUserNum),2,BigDecimal.ROUND_HALF_EVEN))+"%",otherOrderMoney,flag? 0+"%" :(otherOrderMoney.divide(totalOrderMoney,2,BigDecimal.ROUND_HALF_EVEN)+"%")));
        //饼状图数据
        List<KcUserStatisticsVO> userStatisticsVOList = new ArrayList<>();
        for(BizSaleStatisticsBySexDTO saleStatisticsBySexDTO : bizSaleStatisticsBySexDTOList){
            userStatisticsVOList.add(new KcUserStatisticsVO(saleStatisticsBySexDTO.getSex(),saleStatisticsBySexDTO.getOrderMoney()+""));
        }

        Map<String,Object> mapData = new HashMap<>();
        mapData.put("pieChartData",userStatisticsVOList);
        mapData.put("listData",bizSaleStatisticsBySexDTOList);
        return AjaxResult.success(mapData);
    }

    /**
     * 获取所有订单金额
     * @param bizOrderStatisticsQuery
     * @return
     */
    @PreAuthorize("@ss.hasPermi('business:orderStatistics:getAllOrderMoney')")
    @GetMapping("/getAllOrderMoney")
    public AjaxResult getAllOrderMoney(BizOrderStatisticsQuery bizOrderStatisticsQuery){
        List<KcUserStatisticsVO> kcUserStatisticsVOList = bizOrderStatisticsDataService.getOrderMoney(bizOrderStatisticsQuery);
        Map<String,Object> map = new HashMap<>();
        map.put("color",colorList);
        map.put("data",kcUserStatisticsVOList);
        return AjaxResult.success(map);
    }

    /**
     * 获取所有支付订单金额
     * @param bizOrderStatisticsQuery
     * @return
     */
    @PreAuthorize("@ss.hasPermi('business:orderStatistics:getAllPayOrderMoney')")
    @GetMapping("/getAllPayOrderMoney")
    public AjaxResult getAllPayOrderMoney(BizOrderStatisticsQuery bizOrderStatisticsQuery){
        List<KcUserStatisticsVO> kcUserStatisticsVOList = bizOrderStatisticsDataService.getAllPayOrderMoney(bizOrderStatisticsQuery);
        Map<String,Object> map = new HashMap<>();
        map.put("color",colorList);
        map.put("data",kcUserStatisticsVOList);
        return AjaxResult.success(map);
    }

    /**
     * 获取销售排序数据列表
     * @return
     */
    @PreAuthorize("@ss.hasPermi('business:orderStatistics:getSaleRanking')")
    @GetMapping("/getSaleRanking")
    public AjaxResult getSaleRanking(BizOrderStatisticsQuery bizOrderStatisticsQuery,HttpServletResponse response){
        List<BizSaleRankingDTO> bizSaleRankingDTOList = bizOrderStatisticsDataService.getSaleRanking(bizOrderStatisticsQuery);
        if(bizOrderStatisticsQuery.getExport().equals(1)){
            //数据导出
            ExcelUtil<BizSaleRankingDTO> util = new ExcelUtil<>(BizSaleRankingDTO.class);
            Workbook workbook = null;
            try {
                DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
                workbook = util.exportExcelWithoutPersist(bizSaleRankingDTOList, "统计表");
                response.setContentType("application/octet-stream");
                response.setHeader("Content-disposition", String.format("attachment;filename=%s.xlsx",
                        URLEncoder.encode(String.format("统计表"),
                                "UTF-8")));
                response.flushBuffer();
                workbook.write(response.getOutputStream());
            } catch (Exception e) {
                log.error("下载文件失败", e);
            } finally {
                if (null != workbook) {
                    try {
                        workbook.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
        return AjaxResult.success(bizSaleRankingDTOList);
    }
    /**
     * 获取销售收入統計
     * @return
     */
    @PreAuthorize("@ss.hasPermi('business:orderStatistics:getSaleIncomeList')")
    @GetMapping("/getSaleIncomeList")
    public AjaxResult getSaleIncomeList(BizOrderStatisticsQuery bizOrderStatisticsQuery,HttpServletResponse response){
        List<BizOrderStatisticsIncomeDetailsDTO> statisticsIncomeDetailsDTOS = bizOrderStatisticsDataService.getSaleIncomeList(bizOrderStatisticsQuery);
        if(bizOrderStatisticsQuery.getExport().equals(1)){
            //数据导出
            ExcelUtil<BizOrderStatisticsIncomeDetailsDTO> util = new ExcelUtil<>(BizOrderStatisticsIncomeDetailsDTO.class);
            Workbook workbook = null;
            try {
                workbook = util.exportExcelWithoutPersist(statisticsIncomeDetailsDTOS, "统计表");
                response.setContentType("application/octet-stream");
                response.setHeader("Content-disposition", String.format("attachment;filename=%s.xlsx",
                        URLEncoder.encode(String.format("GMV&实际收入毛利对比"),
                                "UTF-8")));
                response.flushBuffer();
                workbook.write(response.getOutputStream());
            } catch (Exception e) {
                log.error("下载文件失败", e);
            } finally {
                if (null != workbook) {
                    try {
                        workbook.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
        return AjaxResult.success(statisticsIncomeDetailsDTOS);
    }
    /**
     * 获取销售收入柱状图
     * @return
     */
    @PreAuthorize("@ss.hasPermi('business:orderStatistics:getSaleIncomeChart')")
    @GetMapping("/getSaleIncomeChart")
    public AjaxResult getSaleIncomeChart(BizOrderStatisticsQuery bizOrderStatisticsQuery){
        List<BizOrderStatisticsIncomeDetailsDTO> statisticsIncomeDetailsDTOS = bizOrderStatisticsDataService.getSaleIncomeList(bizOrderStatisticsQuery);
        List<String> dateList = new ArrayList<>();
        List<String> saleMoneyList = new ArrayList<>();
        List<String> incomeList = new ArrayList<>();
        List<String> saleCostList = new ArrayList<>();
        List<String> saleProfitList = new ArrayList<>();
        for(BizOrderStatisticsIncomeDetailsDTO incomeDetailsDTO : statisticsIncomeDetailsDTOS){
            dateList.add(incomeDetailsDTO.getDate());
            saleMoneyList.add(incomeDetailsDTO.getSaleMoney().toString());
            incomeList.add(incomeDetailsDTO.getIncome().toString());
            saleCostList.add(incomeDetailsDTO.getSaleCost().toString());
            saleProfitList.add(incomeDetailsDTO.getSaleProfit().toString());
        }
        //颜色列表
        List<String> colorList = Arrays.asList("#5B8FF9", "#5AD8A6", "#5D7092", "#E8684A");
        //拼装数据
        List<BizOrderStatisticsBrokenLineDataDTO> brokenLineDataDTOS = new ArrayList<>();
        brokenLineDataDTOS.add(new BizOrderStatisticsBrokenLineDataDTO("销售总额","bar","总量",true,saleMoneyList));
        brokenLineDataDTOS.add(new BizOrderStatisticsBrokenLineDataDTO("实际收入","bar","总量",true,incomeList));
        brokenLineDataDTOS.add(new BizOrderStatisticsBrokenLineDataDTO("销售成本","bar","总量",true,saleCostList));
        brokenLineDataDTOS.add(new BizOrderStatisticsBrokenLineDataDTO("销售毛利","bar","总量",true,saleProfitList));

        Map<String,Object> map = new HashMap<>();
        map.put("color",colorList);
        map.put("data",dateList);
        map.put("series",brokenLineDataDTOS);
        return AjaxResult.success(map);
    }

    @GetMapping("/test")
    public AjaxResult test() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
//        String attributeName = "OrderUserNum";
//        bizOrderStatisticsDataService.getSaleDateByWeek(attributeName);
        Map<Integer,String> platformMap = new HashMap<>();
        platformMap.put(0,"官方");
        platformMap.put(-1,"景区");
        platformMap.put(-2,"名家");
        platformMap.put(-3,"市场");
        platformMap.put(-4,"商家");
        for(Map.Entry<Integer,String> entry : platformMap.entrySet()){
            log.info("key={},value={}",entry.getKey(),entry.getValue());
        }
        return AjaxResult.success();
    }



}
